Introduction to Octave by Sandeep Nagar

Introduction to Octave by Sandeep Nagar

Author:Sandeep Nagar
Language: eng
Format: epub
Publisher: Apress, Berkeley, CA


The randp() Function

This function returns a matrix with Poisson distributed random elements with a mean value parameter given by the first argument. For example, if first argument is 1, then random numbers within the Poisson distribution having a mean of 1 are produced.

1 >> randp(1)

2 ans = 2

3 >> randp(1)

4 ans = 0

5 >> randp(1)

6 ans = 0

7 >> randp(1)

8 ans = 2

9 >> randp(1)

10 ans = 0

11 >> randp(1)

12 ans = 1

13 >> randp(1)

14 ans = 3

On the other hand, a matrix can also be produced by giving dimensions of the matrix as other arguments. Arguments can be presented as numbers separated by commas or as an array having a description of dimensions.

1 >> randp(1,2,3) % mean=1, matrix of 2 rows and 3 columns

2 ans =

3

4 1 0 1

5 0 0 1

6

7 >> randp(1,2,3) % repeating the same command and getting a different set of numbers

8 ans =

9

10 1 3 1

11 1 1 2

12

13 >> randp(2,2,3) % mean=2, matrix of 2 rows and 3 columns

14 ans =

15

16 1 3 2

17 2 0 1

18

19 >> randp(2,2,3) % repeating the same command and getting a different set of numbers

20 ans =

21

22 3 0 0

23 2 3 0

24

25 >> randp(20,4,3) % mean=20, matrix of 4 rows and 3 columns

26 ans =

27

28 21 17 22

29 23 21 13

30 17 24 12

31 30 13 13

32

33 >> randp(20,4,3) % repeating the same commands and getting different set of numbers

34 ans =

35

36 25 29 27

37 28 11 20

38 17 22 36

39 21 16 18

40

41 >> randp(20,[4,3]) % Inputting matrix dimensions as an array (4 rows and 3 columns)

42 ans =

43

44 18 18 19

45 29 22 13

46 19 25 24

47 20 18 17

48

49 >> randp(20,[3,4]) %% Inputting matrix dimensions as an array (3 rows and 4 columns)

50 ans =

51

52 19 19 25 28

53 21 17 10 29

54 18 20 19 24



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.